package com.example.demo.jucConcurrent.LockSupport;

import java.util.concurrent.locks.LockSupport;

public class InterruptDemo {
    public static void main(String[] args) {

        MyThread01 myThread = new MyThread01(Thread.currentThread());
        myThread.start();
        System.out.println("before park");
        //获取许可
        LockSupport.park("ParkAndUnparkDemo");
        System.out.println("After park");
    }
}

class  MyThread01 extends  Thread{
    private  Object object;

    public MyThread01(Object object){
        this.object = object;
    }


    @Override
    public void run() {
        System.out.println("before interrupt");

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        Thread thread = (Thread) object;
        //中断线程
        thread.interrupt();
        System.out.println("after interrupt");
    }
}
